package com.qfjy.homework.songyangyang;

import java.util.List;

/**
 * @author:宋阳阳
 * @date:2022/6/29 20:46
 * @version:1.0
 * PersonnelStructure 人员结构  使用 Employee 类来创建和打印员工的层次结构。
 */
public class PersonnelStructure {

    public static void main(String[] args) {
        Employee CEO = new Employee("John","CEO", 30000);

        Employee headSales = new Employee("Robert","Head Sales", 20000);

        Employee headMarketing = new Employee("Michel","Head Marketing", 20000);

        Employee clerk1 = new Employee("Laura","Marketing", 10000);
        Employee clerk2 = new Employee("Bob","Marketing", 10000);

        Employee salesExecutive1 = new Employee("Richard","Sales", 10000);
        Employee salesExecutive2 = new Employee("Rob","Sales", 10000);

        CEO.add(headSales);
        CEO.add(headMarketing);




        headSales.add(salesExecutive1);
        headSales.add(salesExecutive2);

        headMarketing.add(clerk1);
        headMarketing.add(clerk2);

        //打印该组织的所有员工
        System.out.println(CEO);
        List<Employee> ceo = CEO.getSubordinates();
        for (Employee employee : ceo) {
            System.out.println("CEO下属一级员工" + employee);
            List<Employee> ceoDowns = employee.getSubordinates();
            for (Employee employee1 : ceoDowns) {
                System.out.println("CEO下属二级员工" + employee1);
            }
        }

    }
    /**
     * 输出结果为
     * Employee{name='John', dept='CEO', salary=30000}
     * CEO下属一级员工Employee{name='Robert', dept='Head Sales', salary=20000}
     * CEO下属二级员工Employee{name='Richard', dept='Sales', salary=10000}
     * CEO下属二级员工Employee{name='Rob', dept='Sales', salary=10000}
     *
     * CEO下属一级员工Employee{name='Michel', dept='Head Marketing', salary=20000}
     * CEO下属二级员工Employee{name='Laura', dept='Marketing', salary=10000}
     * CEO下属二级员工Employee{name='Bob', dept='Marketing', salary=10000}
     */


}
